package com.xuecheng.auth.interfaces.web;

import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2024-09-01  15:38
 */
@Api(tags = "认证测试接口")
@RestController
@RequestMapping("/test")
public class TestApi {

    @RequestMapping("/login-success")
    public String loginSuccess(){
        return "登录成功";
    }

    @RequestMapping("/user/{id}")
    public String getUser(@PathVariable("id") String id){

        return id;
    }

    @PreAuthorize("hasAuthority('p1')")
    @RequestMapping("/r/r1")
    public String r1(){
        return "访问r1资源";
    }

    @PreAuthorize("hasAuthority('p2')")
    @RequestMapping("/r/r2")
    public String r2(){
        return "访问r2资源";
    }
}
